<template>
	<el-container>
		<el-header style="height: auto;">
			<sc-select-filter :data="filterData" :label-width="80" @on-change="filterChange"></sc-select-filter>
		</el-header>
		<el-main class="nopadding">
		<GanttComponent class="left-container" :readOnly="false" :tasks="tasks"></GanttComponent>
		</el-main>
	</el-container>
</template>

<script>
import GanttComponent from '@/views/office/task/gantt/ganttView';
import scSelectFilter from '@/components/scSelectFilter'
export default {
	name: 'Break Down',
	components: {GanttComponent,scSelectFilter},
	data () {
		return {
			filterData: [
				{
					title: "日期范围",
					key: "date",
					multiple: false,
					options: [
						{
							label: "全部",
							value: ""
						},
						{
							label: "今日",
							value: "1"
						},
						{
							label: "明日",
							value: "2"
						},
						{
							label: "一周内",
							value: "3"
						},
						{
							label: "一月内",
							value: "4"
						},
						{
							label: "一月后",
							value: "5"
						}
					]
				},
				{
					title: "任务类型",
					key: "taskType",
					multiple: false,
					options:[{
						label: "全部",
						value: ""
					}]
				}],
			tasks: {
				data: [],
				links: []
			},
		}
	},
	mounted() {
		this.getSysDicByCode();
		this.filterChange();
	},
	methods:{
		async getSysDicByCode()
		{
			var res = await this.$API.system.sysDic.getSysDicByCode.get({code:'taskType'});
			if (res.code == 200) {
				this.filterData[1].options=this.filterData[1].options.concat(res.data);
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async filterChange(data){
			var res = await this.$API.office.task.getAssignmentTaskList.get(data);
			if (res.code == 200) {
				this.tasks = res.data;
			} else {
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
	}
}
</script>

<style>
html, body {
	height: 100%;
	margin: 0;
	padding: 0;
}
.container {
	height: 100vh;
	width: 100%;
}
.left-container {
	overflow: hidden;
	position: relative;
	height: 100%;
}
</style>
